home *** CD-ROM | disk | FTP | other *** search
-
- #include "kalaha.h"
-
-
-
- static void plot_arrow(wimp_redrawstr r);
-
- static void find_hollow_details(int *nump, int *xp, int *yp, char *name, int p, wimp_redrawstr r);
-
-
-
-
-
-
- void plot_arrow(wimp_redrawstr r)
- {
- int x, y;
- char name[12];
- sprite_factors scales;
- sprite_pixtrans cols[16];
- sprite_id sid;
-
-
- sid.tag = sprite_id_name;
- sid.s.name = name;
- x = coords_x_toscreen(SIDEBORDER+5*HOLLWID/2, (coords_cvtstr *)&r.box);
- y = coords_y_toscreen(MIDROW, (coords_cvtstr *)&r.box);
-
- if (botgo)
- {
- strcpy(name, "dnarrow");
- }
- else
- {
- if (automove || starterplayer == UservUser)
- strcpy(name, "uparrow");
- else
- strcpy(name, "uparrow_c");
- }
- wimpt_noerr(wimp_readpixtrans(resspr_area(), &sid, &scales, cols));
- wimpt_noerr(sprite_put_scaled(resspr_area(), &sid, 0, x, y, &scales, cols));
-
- }
-
-
-
-
- void find_hollow_details(int *nump, int *xp, int *yp, char *name, int p, wimp_redrawstr r)
- {
- if (p==6 || p==13)
- {
- strcpy(name, "bighollow");
- *yp = coords_y_toscreen(MIDROW, (coords_cvtstr *)&r.box);
- if (p==6)
- {
- *xp = coords_x_toscreen(SIDEBORDER+4*HOLLWID, (coords_cvtstr *)&r.box);
- *nump = bottot;
- }
- else
- {
- *xp = coords_x_toscreen(SIDEBORDER , (coords_cvtstr *)&r.box);
- *nump = toptot;
- }
- }
- else
- {
- strcpy(name, "hollow");
- if (p<6)
- {
- *xp = coords_x_toscreen(SIDEBORDER+p*HOLLWID, (coords_cvtstr *)&r.box);
- *yp = coords_y_toscreen(BOTROW, (coords_cvtstr *)&r.box);
- *nump = bot[p];
- }
- else
- {
- *xp = coords_x_toscreen(SIDEBORDER+(12-p)*HOLLWID, (coords_cvtstr *)&r.box);
- *yp = coords_y_toscreen(TOPROW, (coords_cvtstr *)&r.box);
- *nump = top[p-7];
- }
- }
- }
-
-
-
-
-
- void plot_one_hollow(int p, wimp_redrawstr r)
- {
- /* p is 0...13 or >=14. >=14 means arrow, others c-clockwise from bot left */
-
- char name[12];
- sprite_factors scales;
- sprite_pixtrans cols[16];
- sprite_id sid;
- int num, x, y, n, roomfor;
-
- static char spiral1[30][2] = { {2,2}, {2,4}, {4,4}, {4,2}, {4,0}, {2,0},
- {0,0}, {0,2}, {0,4}, {0,6}, {2,6}, {4,6}, {6,6}, {6,4}, {6,2}, {6,0},
- {3,3}, {3,1}, {1,1}, {1,3}, {1,5}, {3,5}, {5,5}, {5,3}, {5,1},
- {2,2}, {2,4}, {4,4}, {4,2}, {3,3} };
-
- static char spiral2[53][2] = { {2,2}, {4,2}, {6,2}, {8,2}, {10,2}, {12,2},
- {12,4}, {10,4}, {8,4}, {6,4}, {4,4}, {2,4}, {0,4},
- {0,2}, {0,0}, {2,0}, {4,0}, {6,0}, {8,0}, {10,0}, {12,0}, {14,0},
- {14,2}, {14,4}, {14,6}, {12,6}, {10,6}, {8,6}, {6,6}, {4,6}, {2,6}, {0,6},
-
- {3,3}, {5,3}, {7,3}, {9,3}, {11,3}, {13,3},
- {13,5}, {11,5}, {9,5}, {7,5}, {5,5}, {3,5}, {1,5},
- {1,3}, {1,1}, {3,1},{5,1},{7,1},{9,1},{11,1},{13,1} };
-
-
- sid.tag = sprite_id_name;
- sid.s.name = name;
-
-
- if (p>=14)
- {
- plot_arrow(r);
- return;
- }
-
- find_hollow_details(&num, &x, &y, name, p, r);
- /* now x,y is bottomleft of relevant hollow, and sprite named */
-
- wimpt_noerr(wimp_readpixtrans(resspr_area(), &sid, &scales, cols));
- wimpt_noerr(sprite_put_scaled(resspr_area(), &sid, 0, x, y, &scales, cols));
- if (num == 0) return;
-
- strcpy(name, "gb");
- wimpt_noerr(wimp_readpixtrans(resspr_area(), &sid, &scales, cols));
-
-
- roomfor = (p==6 || p==13) ? 67 : 30 ;
- n = 0;
- while ( n < roomfor && n < num )
- {
- int xx, yy;
- if (p==6 || p==13)
- {
- xx = x + spiral2[n%53][0]*HALFBALL + 12;
- yy = y + spiral2[n%53][1]*HALFBALL + 4;
- }
- else
- {
- xx = x + spiral1[n][0]*HALFBALL + 4;
- yy = y + spiral1[n][1]*HALFBALL + 4;
- }
- wimpt_noerr(sprite_put_scaled(resspr_area(), &sid, 8, xx, yy, &scales, cols));
- n++;
- }
- }
-
-
-
-
-
-
- void redraw_main_window(wimp_w handle)
- {
- int more;
- wimp_redrawstr r;
- int p;
- wimp_box hollow;
-
- r.w = handle;
- wimpt_noerr(wimp_redraw_wind(&r, &more));
-
- while (more)
- {
- for (p=0; p<15; p++)
- {
- find_hollow_box(&hollow, p);
- coords_box_toscreen(&hollow, (coords_cvtstr *)&r.box );
- if (coords_boxesoverlap(&hollow, &r.g))
- {plot_one_hollow(p, r);}
- }
- wimpt_noerr(wimp_get_rectangle(&r, &more));
- }
-
- }
-
-